<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="日志详情" width="50%">
    <BasicForm @register="registerForm" />
  </BasicDrawer>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { formSchema } from './log.data';

  export default defineComponent({
    name: 'OptLogDrawer',
    components: { BasicDrawer, BasicForm },
    setup() {
      const [registerForm, { resetFields, setFieldsValue }] = useForm({
        labelWidth: 100,
        schemas: formSchema,
        showActionButtonGroup: false,
        baseColProps: { lg: 12, md: 24 },
      });

      const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => {
        resetFields();
        setDrawerProps({ confirmLoading: false });
        setFieldsValue({
          ...data.record,
        });
      });

      return {
        registerDrawer,
        registerForm,
      };
    },
  });
</script>
